package org.example;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 九转苍翎
 * Date: 2025/8/23
 * Time: 11:26
 */
public class Solution {
    public int findMin(int[] nums) {
        int length = nums.length,left = 0,right = length - 1,mid =  length / 2;
        while (left < right) {
            if(nums[mid] < nums[length - 1]){
                right = mid;
            }
            if(nums[mid] > nums[length - 1]){
                left = mid + 1;
            }
            mid = left + (right - left) / 2;
        }
        return nums[left];
    }
    public static void main(String[] args) {
        Solution solution = new Solution();
        int min = solution.findMin(new int[] {4,5,6,7,0,1,2});
        System.out.println(min);
    }
}